package com.demo.redis.pubsub;

import redis.clients.jedis.JedisPool;

/**
 * 参考：https://blog.csdn.net/lihao21/article/details/48370687
 * https://blog.csdn.net/u011489043/article/details/78780255
 * https://www.cnblogs.com/foundwant/p/6382083.html
 * https://www.cnblogs.com/meetzy/p/7986956.html
 */
public class Publisher {
    private final JedisPool jedisPool;
    private final String channel;

    public Publisher(JedisPool jedisPool, String channel) {
        this.jedisPool = jedisPool;
        this.channel = channel;
    }

    public void pubMsg(String msg) {
        jedisPool.getResource().publish(channel, msg);
    }
}
